/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package model.Entity.SIS;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author user12
 */
@Entity
@Table(name = "SIS_COURSE_DEGREES")
@NamedQueries({
    @NamedQuery(name = "CourseDegrees.findAll", query = "SELECT s FROM CourseDegree s"),
    @NamedQuery(name = "CourseDegrees.findByCourseNo", query = "SELECT s FROM CourseDegree s WHERE s.courseDegreePK.courseNo = :courseNo"),
    @NamedQuery(name = "CourseDegrees.findByDegreeCode", query = "SELECT s FROM CourseDegree s WHERE s.courseDegreePK.degreeCode = :degreeCode"),
    @NamedQuery(name = "CourseDegrees.findByEntryDate", query = "SELECT s FROM CourseDegree s WHERE s.entryDate = :entryDate"),
    @NamedQuery(name = "CourseDegrees.findByTerminal", query = "SELECT s FROM CourseDegree s WHERE s.terminal = :terminal"),
    @NamedQuery(name = "CourseDegrees.findByOsUser", query = "SELECT s FROM CourseDegree s WHERE s.osUser = :osUser")})
public class CourseDegree implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CourseDegreePK courseDegreePK;
    @Basic(optional = false)
    @NotNull
    @Column(name = "ENTRY_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date entryDate;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    private String terminal;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "OS_USER")
    private String osUser;
    @JoinColumn(name = "COURSE_NO", referencedColumnName = "COURSE_NO", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Course course;

    public CourseDegree() {
    }

    public CourseDegree(CourseDegreePK courseDegreePK) {
        this.courseDegreePK = courseDegreePK;
    }

    public CourseDegree(CourseDegreePK courseDegreePK, Date entryDate, String terminal, String osUser) {
        this.courseDegreePK = courseDegreePK;
        this.entryDate = entryDate;
        this.terminal = terminal;
        this.osUser = osUser;
    }

    public CourseDegree(short courseNo, short degreeCode) {
        this.courseDegreePK = new CourseDegreePK(courseNo, degreeCode);
    }

    public CourseDegreePK getCourseDegreePK() {
        return courseDegreePK;
    }

    public void setCourseDegreesPK(CourseDegreePK courseDegreePK) {
        this.courseDegreePK = courseDegreePK;
    }

    public Date getEntryDate() {
        return entryDate;
    }

    public void setEntryDate(Date entryDate) {
        this.entryDate = entryDate;
    }

    public String getTerminal() {
        return terminal;
    }

    public void setTerminal(String terminal) {
        this.terminal = terminal;
    }

    public String getOsUser() {
        return osUser;
    }

    public void setOsUser(String osUser) {
        this.osUser = osUser;
    }

    public Course getCourses() {
        return course;
    }

    public void setSisCourses(Course course) {
        this.course = course;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (courseDegreePK != null ? courseDegreePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CourseDegree)) {
            return false;
        }
        CourseDegree other = (CourseDegree) object;
        if ((this.courseDegreePK == null && other.courseDegreePK != null) || (this.courseDegreePK != null && !this.courseDegreePK.equals(other.courseDegreePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.CourseDegrees[ sisCourseDegreesPK=" + courseDegreePK + " ]";
    }
    
}
